package example.entity;

import example.service.BookService;
import example.service.UserService;

import java.util.Date;

/**
 * @author 张心怡
 * @date 2024/12/16
 */
public class Borrow {
    private int borrowId;
    private int userId;
    private int bookId;
    private Date borrowDate;
    private Date dueDate;
    private Date returnDate;

    private String username;
    private String bookname;

    public String getUsername() {
        return UserService.getById(userId).getUsername();
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getBookname() {
        return BookService.getBookById(bookId).getName();
    }

    public void setBookname(String bookname) {
        this.bookname = bookname;
    }

    public Date getReturnDate() {
        return returnDate;
    }

    public void setReturnDate(Date returnDate) {
        this.returnDate = returnDate;
    }

    public Borrow() {
    }

    // 构造函数、Getter和Setter方法
    public Borrow(int borrowId, int userId, int bookId, Date borrowDate, Date dueDate, Date returnDate) {
        this.borrowId = borrowId;
        this.userId = userId;
        this.bookId = bookId;
        this.borrowDate = borrowDate;
        this.dueDate = dueDate;
        this.returnDate = returnDate;
    }

    public int getBorrowId() {
        return borrowId;
    }

    public void setBorrowId(int borrowId) {
        this.borrowId = borrowId;
    }

    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    public int getBookId() {
        return bookId;
    }

    public void setBookId(int bookId) {
        this.bookId = bookId;
    }

    public Date getBorrowDate() {
        return borrowDate;
    }

    public void setBorrowDate(Date borrowDate) {
        this.borrowDate = borrowDate;
    }

    public Date getDueDate() {
        return dueDate;
    }

    public void setDueDate(Date dueDate) {
        this.dueDate = dueDate;
    }
}
